#include "mainpage.h"
#include "ui_mainpage.h"
#include "netmain.h"

MainPage *MainPage::obj = nullptr;

MainPage::MainPage(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::MainPage)
{
    ui->setupUi(this);
//    connect(NetMain::getObject(), &NetMain::deviceValue,
//            this, &MainPage::deviceValueSlot);
    //qt4
//    connect(NetMain::getObject(), SIGNAL(deviceValue(int,int,bool)),
//            this, SLOT(deviceValueSlot(int,int,bool)));
    //qt5
    void (NetMain::*dv1)(int, int, bool) = &NetMain::deviceValue;
    void (MainPage::*dvs1)(int, int, bool) = &MainPage::deviceValueSlot;
    connect(NetMain::getObject(), dv1, this, dvs1);
}

MainPage *MainPage::getObject()
{
    if(obj == nullptr)
        obj = new MainPage;
    return obj;
}

MainPage::~MainPage()
{
    delete ui;
}

void MainPage::deviceValueSlot(int deviceTypeId, int deviceTypeIndex, double value)
{

}

void MainPage::deviceValueSlot(int deviceTypeId, int deviceTypeIndex, bool value)
{

}

void MainPage::deviceValueSlot(int deviceTypeId, int deviceTypeIndex, QString value)
{

}

